﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
    <title>Light: Test/LightTestRhino/LightTestRhino.cs Source File</title>
    <link href="/Content/Help.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/tabs.css" rel="stylesheet" type="text/css" />
    <link href="/Content/css/doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <div id="header">
        <img id="logo" alt="StateForge" src="/Content/Images/StateForgeLogo.png" />
        <div id="title">
            <h1>
                C# examples using state machines generated by StateBuilderDotNet
            </h1>
            <h3>
                Light: Test/LightTestRhino/LightTestRhino.cs Source File
            </h3>
        </div>
        <div id="menucontainer">
            <ul id="menu">
                <li><a href="/">Home</a></li>
                <li><a href="/Home/Download">Downloads</a></li>
                <li><a href="/Help/state-machine-tools.aspx">Help</a></li>
                <li><a href="/Home/Faq">F.A.Q</a></li>
                <li><a href="/Home/About">Contact us</a></li>
            </ul>
        </div>
    </div>
<!-- Generated by Doxygen 1.7.4 -->
  <div id="navrow1" class="tabs">
    <ul class="tablist">
      <li><a href="index.html"><span>Main&#160;Page</span></a></li>
      <li><a href="namespaces.html"><span>Namespaces</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div id="navrow2" class="tabs2">
    <ul class="tablist">
      <li><a href="files.html"><span>File&#160;List</span></a></li>
    </ul>
  </div>
<div class="header">
  <div class="headertitle">
<div class="title">Test/LightTestRhino/LightTestRhino.cs</div>  </div>
</div>
<div class="contents">
<a href="_light_test_rhino_8cs.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 ﻿
<a name="l00002"></a>00002 
<a name="l00003"></a>00003 <span class="keyword">namespace </span>StateForge.Examples.Light
<a name="l00004"></a>00004 {
<a name="l00005"></a>00005     <span class="keyword">using</span> System;
<a name="l00006"></a>00006     <span class="keyword">using</span> NUnit.Framework;
<a name="l00007"></a>00007     <span class="keyword">using</span> StateForge.StateMachine;
<a name="l00008"></a>00008     <span class="keyword">using</span> Rhino.Mocks;
<a name="l00009"></a>00009 
<a name="l00010"></a>00010     [TestFixture]
<a name="l00011"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html">00011</a>     <span class="keyword">class </span><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html">LightTestRhino</a>
<a name="l00012"></a>00012     {
<a name="l00013"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#aff114fee47fd1fa79c4c4c0d69d1b0b8">00013</a>         <span class="keyword">private</span> LightContext <a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#aff114fee47fd1fa79c4c4c0d69d1b0b8">lightContext</a>;
<a name="l00014"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a7b8b3476d19164520bff70c455807107">00014</a>         <span class="keyword">private</span> MockRepository <a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a7b8b3476d19164520bff70c455807107">repository</a>;
<a name="l00015"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a8d0466d85d600192028c046111bf3603">00015</a>         <span class="keyword">private</span> <a class="code" href="interface_state_forge_1_1_examples_1_1_light_1_1_i_light_actuator.html">ILightActuator</a> <a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a8d0466d85d600192028c046111bf3603">lightActuator</a>;
<a name="l00016"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a351c95887a4c31770bd2487fa47f2621">00016</a>         <span class="keyword">private</span> IObserver <a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a351c95887a4c31770bd2487fa47f2621">observer</a>;
<a name="l00017"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#ab15e926e4bc44562b7691d7abd398d58">00017</a>         <span class="keyword">private</span> <span class="keyword">static</span> String contextName = <span class="stringliteral">&quot;LightContext&quot;</span>;
<a name="l00018"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#af85d0738d64fab59297b6ffc94baa151">00018</a>         <span class="keyword">private</span> <span class="keywordtype">string</span> current, next, <a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#af85d0738d64fab59297b6ffc94baa151">transition</a>;
<a name="l00019"></a>00019 
<a name="l00020"></a>00020         [SetUp]
<a name="l00021"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a320da2cb25be6b5d0c72907f0d6e406a">00021</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> Setup()
<a name="l00022"></a>00022         {
<a name="l00023"></a>00023             repository = <span class="keyword">new</span> MockRepository();
<a name="l00024"></a>00024             lightActuator = repository.StrictMock&lt;<a class="code" href="interface_state_forge_1_1_examples_1_1_light_1_1_i_light_actuator.html">ILightActuator</a>&gt;();
<a name="l00025"></a>00025             observer = repository.StrictMock&lt;IObserver&gt;();
<a name="l00026"></a>00026             lightContext = <span class="keyword">new</span> LightContext(lightActuator);
<a name="l00027"></a>00027             lightContext.Observer = observer;
<a name="l00028"></a>00028         }
<a name="l00029"></a>00029 
<a name="l00030"></a>00030         [TearDown]
<a name="l00031"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a3ac4005fa2cf7d1d66f7e417bcaf57f1">00031</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> TearDown()
<a name="l00032"></a>00032         {
<a name="l00033"></a>00033 
<a name="l00034"></a>00034         }
<a name="l00035"></a>00035 
<a name="l00036"></a>00036         [Test]
<a name="l00037"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#ad8d26589bb776a8601c521f1afb205cd">00037</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> On()
<a name="l00038"></a>00038         {
<a name="l00039"></a>00039             <span class="keyword">using</span> (repository.Record())
<a name="l00040"></a>00040             {
<a name="l00041"></a>00041                 <span class="keyword">using</span> (repository.Ordered())
<a name="l00042"></a>00042                 {
<a name="l00043"></a>00043                     current = <span class="stringliteral">&quot;Off&quot;</span>; next = <span class="stringliteral">&quot;On&quot;</span>; transition = <span class="stringliteral">&quot;EvOn&quot;</span>;
<a name="l00044"></a>00044                     Expect.Call(() =&gt; observer.OnTransitionBegin(contextName, current, next, transition));
<a name="l00045"></a>00045                     Expect.Call(() =&gt; observer.OnExit(contextName, current));
<a name="l00046"></a>00046                     Expect.Call(() =&gt; observer.OnEntry(contextName, next));
<a name="l00047"></a>00047                     Expect.Call(() =&gt; lightActuator.DoOn());
<a name="l00048"></a>00048                     Expect.Call(() =&gt; observer.OnTransitionEnd(contextName, current, next, transition));
<a name="l00049"></a>00049                 }
<a name="l00050"></a>00050             }
<a name="l00051"></a>00051 
<a name="l00052"></a>00052             <span class="keyword">using</span> (repository.Playback())
<a name="l00053"></a>00053             {
<a name="l00054"></a>00054                 lightContext.EvOn();
<a name="l00055"></a>00055             }
<a name="l00056"></a>00056         }
<a name="l00057"></a>00057 
<a name="l00058"></a>00058         [Test]
<a name="l00059"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a157b72924e5b60d1667dccccb88ab02b">00059</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> Off()
<a name="l00060"></a>00060         {
<a name="l00061"></a>00061             <span class="keyword">using</span> (repository.Record())
<a name="l00062"></a>00062             {
<a name="l00063"></a>00063                 <span class="keyword">using</span> (repository.Ordered())
<a name="l00064"></a>00064                 {
<a name="l00065"></a>00065                 }
<a name="l00066"></a>00066             }
<a name="l00067"></a>00067 
<a name="l00068"></a>00068             <span class="keyword">using</span> (repository.Playback())
<a name="l00069"></a>00069             {
<a name="l00070"></a>00070                 lightContext.EvOff();
<a name="l00071"></a>00071             }
<a name="l00072"></a>00072         }
<a name="l00073"></a>00073         [Test]
<a name="l00074"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a57b79c77861926e32ff53c5303b76d4e">00074</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> OnOff()
<a name="l00075"></a>00075         {
<a name="l00076"></a>00076             <span class="keyword">using</span> (repository.Record())
<a name="l00077"></a>00077             {
<a name="l00078"></a>00078                 <span class="keyword">using</span> (repository.Ordered())
<a name="l00079"></a>00079                 {
<a name="l00080"></a>00080                     <span class="comment">// lightContext.EvOn();</span>
<a name="l00081"></a>00081                     current = <span class="stringliteral">&quot;Off&quot;</span>; next = <span class="stringliteral">&quot;On&quot;</span>; transition = <span class="stringliteral">&quot;EvOn&quot;</span>;
<a name="l00082"></a>00082                     Expect.Call(() =&gt; observer.OnTransitionBegin(contextName, current, next, transition));
<a name="l00083"></a>00083                     Expect.Call(() =&gt; observer.OnExit(contextName, current));
<a name="l00084"></a>00084                     Expect.Call(() =&gt; observer.OnEntry(contextName, next));
<a name="l00085"></a>00085                     Expect.Call(() =&gt; lightActuator.DoOn());
<a name="l00086"></a>00086                     Expect.Call(() =&gt; observer.OnTransitionEnd(contextName, current, next, transition));
<a name="l00087"></a>00087 
<a name="l00088"></a>00088                     <span class="comment">// lightContext.EvOff();</span>
<a name="l00089"></a>00089                     current = <span class="stringliteral">&quot;On&quot;</span>; next = <span class="stringliteral">&quot;Off&quot;</span>; transition = <span class="stringliteral">&quot;EvOff&quot;</span>;
<a name="l00090"></a>00090                     Expect.Call(() =&gt; observer.OnTransitionBegin(contextName, current, next, transition));
<a name="l00091"></a>00091                     Expect.Call(() =&gt; observer.OnExit(contextName, current));
<a name="l00092"></a>00092                     Expect.Call(() =&gt; observer.OnEntry(contextName, next));
<a name="l00093"></a>00093                     Expect.Call(() =&gt; lightActuator.DoOff());
<a name="l00094"></a>00094                     Expect.Call(() =&gt; observer.OnTransitionEnd(contextName, current, next, transition));
<a name="l00095"></a>00095                 }
<a name="l00096"></a>00096             }
<a name="l00097"></a>00097 
<a name="l00098"></a>00098             <span class="keyword">using</span> (repository.Playback())
<a name="l00099"></a>00099             {
<a name="l00100"></a>00100                 lightContext.EvOn();
<a name="l00101"></a>00101                 lightContext.EvOff();
<a name="l00102"></a>00102             }
<a name="l00103"></a>00103         }
<a name="l00104"></a>00104 
<a name="l00105"></a>00105         [Test]
<a name="l00106"></a><a class="code" href="class_state_forge_1_1_examples_1_1_light_1_1_light_test_rhino.html#a6412e4e6f22534cc652c4df3ff1c7263">00106</a>         <span class="keyword">public</span> <span class="keywordtype">void</span> OnOn()
<a name="l00107"></a>00107         {
<a name="l00108"></a>00108             <span class="keyword">using</span> (repository.Record())
<a name="l00109"></a>00109             {
<a name="l00110"></a>00110                 <span class="keyword">using</span> (repository.Ordered())
<a name="l00111"></a>00111                 {
<a name="l00112"></a>00112                     <span class="comment">// lightContext.EvOn();</span>
<a name="l00113"></a>00113                     current = <span class="stringliteral">&quot;Off&quot;</span>; next = <span class="stringliteral">&quot;On&quot;</span>; transition = <span class="stringliteral">&quot;EvOn&quot;</span>;
<a name="l00114"></a>00114                     Expect.Call(() =&gt; observer.OnTransitionBegin(contextName, current, next, transition));
<a name="l00115"></a>00115                     Expect.Call(() =&gt; observer.OnExit(contextName, current));
<a name="l00116"></a>00116                     Expect.Call(() =&gt; observer.OnEntry(contextName, next));
<a name="l00117"></a>00117                     Expect.Call(() =&gt; lightActuator.DoOn());
<a name="l00118"></a>00118                     Expect.Call(() =&gt; observer.OnTransitionEnd(contextName, current, next, transition));
<a name="l00119"></a>00119                 }
<a name="l00120"></a>00120             }
<a name="l00121"></a>00121 
<a name="l00122"></a>00122             <span class="keyword">using</span> (repository.Playback())
<a name="l00123"></a>00123             {
<a name="l00124"></a>00124                 lightContext.EvOn();
<a name="l00125"></a>00125                 lightContext.EvOn();
<a name="l00126"></a>00126             }
<a name="l00127"></a>00127         }
<a name="l00128"></a>00128     }
<a name="l00129"></a>00129 }
</pre></div></div>
</div>
﻿<div id="footer">
    <hr />
    <p>
        Copyright &copy; 2011 StateForge.</p>
    <hr />
</div>
</body> </html> 
